package com.coders.android.util.validation;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Validar nombre de usuario a partir de expresiones regulares
 * 
 * @author Juan & Jaime
 * @version 0.1
 * 
 * l1nux.deb14n@gmail.com & betoskap84@gmail.com
 *
 */
public class UsernameValidator{
 
	  private Pattern pattern;
	  private Matcher matcher;
 
	  private static final String USERNAME_PATTERN = "^[a-z0-9_-]{3,15}$";
 
	  public UsernameValidator(){
		  pattern = Pattern.compile(USERNAME_PATTERN);
	  }
 
	  /**
	   * Validate username with regular expression
	   * @param username username for validation
	   * @return true valid username, false invalid username
	   */
	  public boolean validate(final String username){
 
		  matcher = pattern.matcher(username);
		  return matcher.matches();
 
	  }
}
